package com.quotes.simulation;

import java.util.*;

import com.quotes.datamodell.Symbol;

public class PositionList 
{
	private List<Position> list = new ArrayList<Position>();
	
	public PositionList() {
	}
	
	public List<Position> getPositions() {
		return list;
	}
	
	public void add(Position position) {
		list.add(position);
	}
	
	public PositionList bySymbol(Symbol symbol) {
		PositionList result = new PositionList();
		
		for (Position position : list) {
			if (position.getBuyOrder().getSymbol().equals(symbol))
				result.add(position);
		}

		return result;
	}

	public PositionList byYahooName(String yahooName) {
		PositionList result = new PositionList();
		
		for (Position position : list) {
			if (position.getBuyOrder().getSymbol().getYahooName() == yahooName)
				result.add(position);
		}

		return result;
	}
	
	public PositionList markedAsToBeSold() {
		PositionList result = new PositionList();
		
		for (Position position : list) {
			if (position.toBeSold())
				result.add(position);
		}

		return result;
	}
	
	public void removeAllMarkedAsToBeSold() {
		list.removeAll(markedAsToBeSold().getPositions());
	}
}
